﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Outpatient.Migrations
{
    /// <inheritdoc />
    public partial class add_optrgstrec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.EnsureSchema(
                name: "Outpatient");

            migrationBuilder.CreateTable(
                name: "OtpRgstRec",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    MdtrtSn = table.Column<string>(type: "text", nullable: false),
                    OtpSetlWay = table.Column<int>(type: "integer", nullable: false),
                    SetlTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    PatnId = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpNo = table.Column<string>(type: "text", nullable: false),
                    PatnName = table.Column<string>(type: "text", nullable: false),
                    OtpSchdRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpSchdRecDetlId = table.Column<Guid>(type: "uuid", nullable: true),
                    OtpRgstTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    MdtrtCertTypeCode = table.Column<string>(type: "text", nullable: false),
                    MdtrtCertNo = table.Column<string>(type: "text", nullable: false),
                    OrderId = table.Column<Guid>(type: "uuid", nullable: true),
                    RefundId = table.Column<Guid>(type: "uuid", nullable: true),
                    RgstStas = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpRgstRec", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OtpRgstType",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpRgstTypeCodg = table.Column<string>(type: "text", nullable: false),
                    OtpRgstTypeName = table.Column<string>(type: "text", nullable: false),
                    DataDictCode = table.Column<string>(type: "text", nullable: false),
                    DataDictName = table.Column<string>(type: "text", nullable: false),
                    MedTypeCode = table.Column<string>(type: "text", nullable: false),
                    MedTypeName = table.Column<string>(type: "text", nullable: false),
                    Amt = table.Column<decimal>(type: "numeric", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpRgstType", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OtpRgstTypeAssocPubItem",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpRgstTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    PubItemCodg = table.Column<string>(type: "text", nullable: false),
                    PubItemName = table.Column<string>(type: "text", nullable: false),
                    PubItemTypeCodg = table.Column<string>(type: "text", nullable: false),
                    PubItemTypeName = table.Column<string>(type: "text", nullable: false),
                    MedChrgitmTypeCode = table.Column<string>(type: "text", nullable: false),
                    MedChrgitmTypeName = table.Column<string>(type: "text", nullable: false),
                    Pric = table.Column<decimal>(type: "numeric", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpRgstTypeAssocPubItem", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpRgstTypeAssocPubItem_OtpRgstType_OtpRgstTypeId",
                        column: x => x.OtpRgstTypeId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpRgstType",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OtpRgstTypeAssocPubItem_OtpRgstTypeId",
                schema: "Outpatient",
                table: "OtpRgstTypeAssocPubItem",
                column: "OtpRgstTypeId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OtpRgstRec",
                schema: "Outpatient");

            migrationBuilder.DropTable(
                name: "OtpRgstTypeAssocPubItem",
                schema: "Outpatient");

            migrationBuilder.DropTable(
                name: "OtpRgstType",
                schema: "Outpatient");
        }
    }
}
